package com.vpen.blog.controller;


import com.vpen.blog.common.ReturnResult;
import com.vpen.blog.entity.User;
import com.vpen.blog.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Vpen
 * @since 2021-07-07
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    UserService userService;


    @GetMapping("/{id}")
    public Object getUser(@PathVariable("id") Integer id){
        ReturnResult result = ReturnResult.getInstance();
        User user = userService.getById(id);
        if (user==null){
            return result.fail();
        }
        return result.success(user);

    }
}
